<%- include header %>
<!-- 主题内容start -->
<table class="table table-bordered table-striped table-condensed table-hover">
    <tr>
        <th class="span3" colspan="5"><h4 style="text-align: center">活动(活动总数：<%- count %>个|当前页：<%- page.num %>/<%- page.pageCount %>页)</h4></th>
    </tr>
    <tr>
        <th class="span3">主题</th>
        <th class="span3">活动时间</th>
        <th class="span2">活动详情</th>
        <th class="span2">参与人数</th>
        <th class="span2">操作</th>
    </tr>
    <% datas.forEach(function(data,index){ %>
    <tr>
        <td>
            <%- data.theme %>
        </td>
        <td>
            <%- data.activeDate %>
        </td>
        <td>
            <a id="t<%- data._id %>">活动详情/编辑</a>
            <div id="win<%- data._id %>" iconCls="icon-save" >
                <form class="form-horizontal" method="post" action="/manager/activeEdit">
                    <input type="hidden"  name="id" value="<%- data._id %>">
                    <fieldset>
                        <legend>活动详情</legend>
                        <div class="control-group">

                            <label class="control-label">活动时间</label>
                            <div class="controls">
                                <input type="text" class="input-xlarge" id="activeDate" name="activeDate" value="<%- data.activeDate %>">
                            </div>
                        </div>
                        <div class="control-group">

                            <label class="control-label">活动地点</label>
                            <div class="controls">
                                <input type="text" class="input-xlarge" id="activeDate" name="addr" value="<%- data.addr %>">
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">活动主题</label>
                            <div class="controls">
                                <input type="text" class="input-xlarge" id="theme" name="theme" value="<%- data.theme %>">
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">详细信息</label>
                            <div class="controls">
                                <!--<textarea style="height: 300px;width: 0px" name="discribe" ><%- data.discribe %></textarea>-->
                                <script id="container" name="discribe" type="text/plain"><%- data.discribe %></script>
                            </div>
                        </div>
                        <div class="control-group">

                            <label class="control-label">活动语言</label>
                            <div class="controls">
                                <input type="text" class="input-xlarge"  name="language" value="<%- data.language %>">
                            </div>
                        </div>
                        <div class="control-group">

                            <label class="control-label">活动费用</label>
                            <div class="controls">
                                <input type="text" class="input-xlarge" id="activeDate" name="cost" value="<%- data.cost %>">
                            </div>
                        </div>
                        <div class="form-actions">
                            <button type="submit" class="btn btn-primary">编辑提交</button>
                        </div>
                    </fieldset>
                </form>
            </div>
        </td>
        <td>
            <a href="/manager/applyUsers?id=<%- data._id %>"><span><%- data.applyNum %>人(点击查看详情)</span>
        </td>
        <td>
            <a class="btn btn-danger btn-small" onclick="goDelete('<%- data._id %>')">删除活动</a>

        </td>
    </tr>

    <script>
        $('#win<%- data._id %>').window({
            title: '菜单',
            width: 950,
            modal: true,
            shadow: true,
            closed: true,
            maximizable : false,
            height: 450,
            resizable:true
        });

        $("#t<%- data._id %>").click(function(){

            $('#win<%- data._id %>').window('open');
        })
    </script>
    <% }) %>
</table>

<hr>

<div class="span12">
    <div id="page1"></div>
</div>
<!-- 主题内容end -->
<%- include footer %>
<script>
    function goDelete(id){
        var prompt=confirm("你确定删除该活动吗？？");

        if(prompt){

            window.location.href="/manager/delActive?id="+id;
        }
    }
    function test(){
//        alert($(window).height())       //可见区域高度
//        alert($(window).width())        //可见区域宽度
//        alert($(document).height())     //整个页面高度
//        alert($(document).width())      //整个页面宽度
        alert($(document).scrollTop())  //获取滚动条到顶部的垂直高度
    }
    $(function(){
        //获得浏览器参数

        $.extend({
            getUrlVars: function(){
                var vars = [];
                var hash;
                var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
                console.log(hashes);
                for(var i = 0; i < hashes.length; i++){
                    hash = hashes[i].split('=');
                    vars.push(hash[0]);
                    vars[hash[0]] = hash[1];
                }
                return vars;
            },
            getUrlVar: function(name){
                return $.getUrlVars()[name];
            }
        });

        //封装浏览器参数
        var composeUrlParams=function(){
            var param='';
            $.each($.getUrlVars(), function(i, item) {
                if(item!='num'){
                    var val=$.getUrlVar(item);
                    if(val) param += "&" + item+"="+val;
                }
            });
            return param;
        }
        var options = {
            currentPage:<%- page.num %>,                //当前页，css样式同其他页不同
            totalPages:<%- page.pageCount %>,           //总页数
            numberOfPages:5,                            //导航最多显示页数
            pageUrl: function(type, page, current) {    //页面跳转
                if(page!=<%- page.num %>){
                    return "/manager/active?num="+ page+composeUrlParams();
                }

            }
        }
        $('#page1').bootstrapPaginator(options);
    })
    var ue = UE.getEditor('container',{
        initialFrameWidth:650,
        enableAutoSave:false,
        initialFrameHeight:171,
        saveInterval:60000,
        toolbars:[[
            'anchor', //锚点
            'undo', //撤销
            'redo', //重做
            'bold', //加粗
            'indent', //首行缩进
            'snapscreen', //截图
            'italic', //斜体
            'underline', //下划线
            'strikethrough', //删除线
            'subscript', //下标
            'fontborder', //字符边框
            'superscript', //上标
            'pasteplain', //纯文本粘贴模式
            'preview', //预览
            'horizontal', //分隔线
            'removeformat', //清除格式
            'time', //时间
            'date', //日期
            'unlink', //取消链接
            'deletecaption', //删除表格标题
            'inserttitle', //插入标题
            'fontfamily', //字体
            'fontsize', //字号
            'paragraph', //段落格式
            'simpleupload', //单图上传
            'insertimage', //多图上传
            'edittable', //表格属性
            'edittd', //单元格属性
            'link', //超链接
            'emotion', //表情
            'spechars', //特殊字符
            'searchreplace', //查询替换
            'map', //Baidu地图
            'help', //帮助
            'justifyleft', //居左对齐
            'justifyright', //居右对齐
            'justifycenter', //居中对齐
            'justifyjustify', //两端对齐
            'forecolor', //字体颜色
            'backcolor', //背景色
            'insertorderedlist', //有序列表
            'insertunorderedlist', //无序列表
            'fullscreen', //全屏
            'inserttable' //插入表格
        ]]
    });
</script>


